<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <style>
     table { font-size: 10px; }
     div { font-size: 12px; }
     p { font-size: 14px; }
     a:link {color: #000000} /* 未访问的链接 */
     a:visited {color: #888888} /* 已访问的链接 */
     a:hover {color: #883333} /* 鼠标移动到链接上 */
     a:active {color: #000000} /* 选定的链接 */
     .yellow {
        background-color: #FFC659;
      }
      .red {
        color:#B54136;
      }
      .green {
        color:#9DB536;
      }
    </style>
</head>
<body>
    <h2>数字货币 (<?= $last_record_time ?>)</h2>
    <p>hello<?= $account_info['account']['nick_name'] ? ' '.$account_info['account']['nick_name']: '' ?>，这里是一些基于 coinmarketcap 市值信息的再计算</p>

<?php foreach([
    '交易量与市值差值(占比倒序)' => ['desc' => '假设市场没有任何信息和人为干预，每个币日交易量排名应与市值排名相符，交易活跃度一致，如若不一致，即是有人为扰动。本排名是将交易量占全天全币种总交易量占比来倒序，即此表排名(#)第一者为当日资金流动最大的货币，*排名*列为市值排名，*差值*列为正说明其已超过了正常的规律异常活跃', 'data' => $total_volume_sort_by_ratio],
    '交易量与市值差值(差倒序)' => ['desc' => '与左列相似，本排名是按左侧列的差值排序，即此表排名(#)第一者为当日资金流动最不符合其市值排名的货币，*排名*列为市值排名，*差值*列为正说明其已超过了正常的规律异常活跃，此表参考第一张表一并分析，差值大不代表一定很疯狂，市值排名低的币微小的扰动都会影响很大的排名变化', 'data' => $total_volume_sort_by_diff],
] as $title => $datas) { ?>
    <div style="background:#eee;float:left;margin-right:10px;margin-top:10px;padding:10px;" title="<?=$datas['desc'] ?>">
    <?=$title ?>
    <table>
      <thead>
        <tr>
          <th>#</th>
          <th>符号</th>
          <th>占比</th>
          <th>排名</th>
          <th>差值</th>
        </tr>
      </thead>
      <tbody>
        <?php foreach ($datas['data'] as $n => $volume) { ?>
        <tr class="focus" symbol="<?=$volume['symbol'] ?>">
          <td><?=$n?></td>
          <td><a href="https://coinmarketcap.com/currencies/<?=$volume['lower_case_name']?>/"><?=$volume['symbol']?></a></td>
          <td><?=$volume['ratio']?></td>
          <td><?=$volume['rank']?></td>
          <td class="<?=$volume['volume_rank_rank']>0?'green':'red'?>" ><?=$volume['volume_rank_rank']?></td>
        </tr>
        <?php } ?>
      </tbody>
    </table>
</div>
<?php } ?>
    

<?php foreach([
    '1h 币值涨' => $percent_change_1h_desc,
    '1h 币值跌' => $percent_change_1h_asc,
] as $title => $datas) { ?>
    <div style="background:#eee;float:left;margin-right:10px;margin-top:10px;padding:10px;">
        <table>
            <?= $title ?>
            <thead>
                <tr>
                    <th>#</th>
                    <th>符号</th>
                    <th>幅度</th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($datas as $n => $data) { ?>
                    <tr class="focus" symbol="<?=$data['symbol'] ?>">
                        <td><?=$n ?></td>
                        <td><a href="https://coinmarketcap.com/currencies/<?=$data['lower_case_name']?>/"><?=$data['symbol']?></a></td>
                        <td><?=$data['percent_change_1h'] ?></td>
                    </tr>
                <?php } ?>
            </tbody>
        </table>
    </div>
    <?php } ?>

<?php foreach([
    '24h 币值涨' => $percent_change_24h_desc,
    '24h 币值跌' => $percent_change_24h_asc,
] as $title => $datas) { ?>
    <div style="background:#eee;float:left;margin-right:10px;margin-top:10px;padding:10px;">
        <table>
            <?= $title ?>
            <thead>
                <tr>
                    <th>#</th>
                    <th>符号</th>
                    <th>幅度</th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($datas as $n => $data) { ?>
                    <tr class="focus" symbol="<?=$data['symbol'] ?>">
                        <td><?=$n ?></td>
                        <td><a href="https://coinmarketcap.com/currencies/<?=$data['lower_case_name']?>/"><?=$data['symbol']?></a></td>
                        <td><?=$data['percent_change_24h'] ?></td>
                    </tr>
                <?php } ?>
            </tbody>
        </table>
    </div>
    <?php } ?>
<?php foreach([
    '每周排名涨幅' => $rank_weekly_rise_asc,
    '每周排名跌幅' => $rank_weekly_rise_desc,
    '每天排名涨幅' => $rank_daily_rise_asc,
    '每天排名跌幅' => $rank_daily_rise_desc,
] as $title => $datas) { ?>
    <div style="background:#eee;float:left;margin-right:10px;margin-top:10px;padding:10px;">
        <table>
            <?= $title ?>
            <thead>
                <tr>
                    <th>#</th>
                    <th>符号</th>
                    <th>变更</th>
                    <th>由</th>
                    <th>至</th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($datas as $n => $data) { ?>
                    <tr class="focus" symbol="<?=$data['symbol'] ?>">
                        <td><?=$n ?></td>
                        <td><a href="https://coinmarketcap.com/currencies/<?=$data['lower_case_name']?>/"><?=$data['symbol']?></a></td>
                        <td><?=$data['rank_rise'] ?></td>
                        <td><?=$data['from_rank'] ?></td>
                        <td><?=$data['to_rank'] ?></td>
                    </tr>
                <?php } ?>
            </tbody>
        </table>
    </div>
    <?php } ?>


    <div style="background:#eee;float:left;margin-right:10px;margin-top:10px;padding:10px;">
        <table>
            最近上新
            <thead>
                <tr>
                    <th>符号</th>
                    <th>上新时间</th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($new_coin_markets as $data) { ?>
                    <tr class="focus" symbol="<?=$data['symbol'] ?>">
                        <td><a href="https://coinmarketcap.com/currencies/<?=$data['lower_case_name']?>/"><?=$data['symbol']?></a></td>
                        <td><?=$data['record_time'] ?></td>
                    </tr>
                <?php } ?>
            </tbody>
        </table>
    </div>

    <script src='https://code.jquery.com/jquery-3.3.1.min.js'></script>
    <script>
        $(function () {

            var last_yellow_elms = [];

            $('.focus').on('mouseover', function () {
                var $this = $(this);
                var symbol = $this.attr('symbol');

                $(last_yellow_elms).each(function () {
                    var $this = $(this);
                    $this.removeClass('yellow');
                });

                last_yellow_elms = $('[symbol="'+symbol+'"]');
                $(last_yellow_elms).each(function () {
                    var $this = $(this);
                    $this.addClass('yellow');
                });
            });

//            $('.focus').on('mouseout', function () {
//                $(last_yellow_elms).each(function () {
//                    var $this = $(this);
//                    $this.removeClass('yellow');
//                });
//            });

            $('.focus').on('click', function () {
                var $this = $(this);
                var symbol = $this.attr('symbol');

                $(last_yellow_elms).each(function () {
                    var $this = $(this);
                    $this.removeClass('yellow');
                });

                last_yellow_elms = $('[symbol="'+symbol+'"]');
                $(last_yellow_elms).each(function () {
                    var $this = $(this);
                    $this.addClass('yellow');
                });
            });
        });
    </script>

</body>
</html>
